package com.zr.action;

import java.io.OutputStream;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

public class ExportExcelAction {
	public  final static String exportExcel(String fileName,String[] Title, List<Object> listContent) {
		String result="系统提示：Excel文件导出成功！";  
		try {
			//定义输出流
			HttpServletResponse resp=ServletActionContext.getResponse(); 
			OutputStream os = resp.getOutputStream();// 取得输出流 
			resp.reset();// 清空输出流  
			resp.setHeader("Content-disposition", "attachment; filename="+ new String(fileName.getBytes("GB2312"),"ISO8859-1"));
			resp.setContentType("application/msexcel");// 定义输出类型  
			
		} catch (Exception e) {
			result="系统提示：Excel文件导出失败，原因："+ e.toString();  
			System.out.println(result);  
			e.printStackTrace();
		}
		return result; 
	}
}
